<template>
  <div class="blueprint">
    <!-- 顶部子模块切换 -->
    <div
      class="child-menu"
      v-show="menuShow"
      @mouseover="menuShow = true"
      @mouseleave="menuShow = false"
    >
      <span
        class="child-menu-item"
        :class="{ active: currentChildItem === 0 }"
        @click="handleChildMenuItemClick(0)"
        >总规</span
      >
      <!-- <div></div> -->
      <span
        class="child-menu-item"
        :class="{ active: currentChildItem === 1 }"
        @click="handleChildMenuItemClick(1)"
        >控规</span
      >
    </div>

    <div
      class="left"
      :class="{ 'left-hide': leftHide }"
      ref="leftRef"
    >
      <div
        class="left-panel"
        v-loading="loading"
        element-loading-background="rgba(0, 0, 0, 0.8)"
      >
        <el-scrollbar>
          <div class="bimNav-title">
            <div
              @click="toolItemClickHandle(item)"
              v-for="(item, index) in toolData"
              :key="index"
              :class="{
                'is-active': activeTool === item.value
              }"
            >
              {{ item.label }}
              <p class="line"></p>
            </div>
          </div>
          <div v-show="activeTool === 'topic'">
            <!-- 头部 -->
            <div class="flex-x main-center">
              <div
                class="header flex-x cross-center"
                style="margin-top: 0"
              >
                <div
                  class="header-icon flex-x main-center cross-center"
                >
                  <img
                    class="background"
                    :src="GuihuaBackground"
                    alt="规划面积背景"
                  />
                  <img
                    class="center"
                    :src="Guihua"
                    alt="规划面积"
                  />
                </div>
                <div
                  class="header-area-wrapper flex-x main-around cross-center"
                  v-if="currentChildItem === 0"
                >
                  <span class="header-title">规划面积</span>
                  <p class="area">
                    60.4
                    <span class="unit">{{
                      squareKilometerSymbol
                    }}</span>
                  </p>
                </div>
                <div
                  class="header-area-wrapper flex-x main-around cross-center"
                  v-if="currentChildItem === 1"
                >
                  <span class="header-title">规划面积</span>
                  <p class="area">
                    29.16
                    <span class="unit">{{
                      squareKilometerSymbol
                    }}</span>
                  </p>
                </div>
              </div>
            </div>
            <img
              class="line-separator"
              :src="LineSeparator"
              alt="分割线"
            />
            <!-- 规划期 -->
            <div class="other-wrapper flex-y">
              <div class="title flex-x cross-center">
                <img
                  class="title-prefix"
                  :src="TitlePrefix"
                  alt="标题前缀"
                />
                <span>规划期：2021-2035</span>
              </div>
              <plan-stepper />
            </div>
            <img
              class="line-separator"
              :src="LineSeparator"
              alt="分割线"
            />
            <!-- 空间结构 -->
            <div
              v-if="currentChildItem === 0"
              class="other-wrapper flex-y"
            >
              <div class="title flex-x cross-center">
                <img
                  class="title-prefix"
                  :src="TitlePrefix"
                  alt="标题前缀"
                />
                <!-- <span>空间结构：两轴三片</span> -->
                <span>空间结构：三区五园五谷</span>
              </div>
              <div
                class="space-structure flex-y cross-start"
              >
                <div class="space-structure-title">
                  <span class="space-structure-title-item"
                    >区(15-20k㎡)</span
                  >
                  <span class="space-structure-title-item"
                    >园(3-5k㎡)</span
                  >
                  <span class="space-structure-title-item"
                    >谷(约1k㎡)</span
                  >
                </div>

                <img
                  class="space-structure-image"
                  :src="SpaceStructure"
                />
                <!-- 两轴 -->
                <!-- <div
                  class="space-structure-item flex-x main-around cross-center flex-1"
                >
                  <span class="label">绛溪河生态轴</span>
                  <span class="label">创新产业联动轴</span>
                  <div
                    class="background flex-x main-center cross-center"
                  >
                    <span>“两轴”</span>
                  </div>
                </div> -->
                <!-- 三片 -->
                <!-- <div
                  class="space-structure-item flex-y main-center cross-center flex-1"
                >
                  <div class="label">
                    <span>成渝国际科教城</span>
                    <span style="float: right"
                      >约15
                      <span class="unit">{{
                        squareKilometerSymbol
                      }}</span></span
                    >
                  </div>
                  <div class="label">
                    <span>中国西部智造示范区</span>
                    <span style="float: right"
                      >约17
                      <span class="unit">{{
                        squareKilometerSymbol
                      }}</span></span
                    >
                  </div>
                  <div class="label">
                    <span>应用性科学中心</span>
                    <span style="float: right"
                      >约19
                      <span class="unit">{{
                        squareKilometerSymbol
                      }}</span></span
                    >
                  </div>
                  <div
                    class="background flex-x main-center cross-center"
                  >
                    <span>“三片”</span>
                  </div>
                </div> -->
              </div>
            </div>
            <!-- 规划指标 -->
            <div v-else class="other-wrapper flex-y">
              <div class="title flex-x cross-center">
                <img
                  class="title-prefix"
                  :src="TitlePrefix"
                  alt="标题前缀"
                />
                <span>规划指标</span>
              </div>
              <div class="plan-target">
                <div class="plan-target-item">
                  <div class="plan-target-item-icon">
                    <img
                      class="background"
                      :src="PlanTargetBackground"
                      alt="规划指标背景"
                    />
                    <Icon
                      name="changzhurenkou"
                      font-size="20"
                      color="white"
                    />
                  </div>
                  <span class="title">人口规模</span>
                  <p class="value">
                    25.5 <span class="unit">万人</span>
                  </p>
                </div>

                <div class="plan-target-item">
                  <div class="plan-target-item-icon">
                    <img
                      class="background"
                      :src="PlanTargetBackground"
                      alt="规划指标背景"
                    />
                    <Icon
                      name="jianzhuyongdi"
                      font-size="20"
                      color="white"
                    />
                  </div>
                  <span class="title">用地规模</span>
                  <p class="value">
                    26.86
                    <span class="unit">{{
                      squareKilometerSymbol
                    }}</span>
                  </p>
                </div>

                <div class="plan-target-item">
                  <div class="plan-target-item-icon">
                    <img
                      class="background"
                      :src="PlanTargetBackground"
                      alt="规划指标背景"
                    />
                    <Icon
                      name="jianzhumianji"
                      font-size="20"
                      color="white"
                    />
                  </div>
                  <span class="title">经营性用地</span>
                  <p class="value">
                    12.57
                    <span class="unit">{{
                      squareKilometerSymbol
                    }}</span>
                  </p>
                </div>
              </div>
            </div>
            <img
              class="line-separator"
              :src="LineSeparator"
              alt="分割线"
            />
            <div
              class="chart-wrapper flex-y"
              v-if="currentChildItem === 0"
            >
              <div class="bimNavArea-title">
                <div
                  @click="toolItemClickHandleArea(item)"
                  v-for="(item, index) in toolData1"
                  :key="index"
                  :class="{
                    'is-active': activeTool1 === item.value
                  }"
                >
                  {{ item.label }}
                  <p class="line"></p>
                </div>
              </div>
              <div
                class="chart-wrapper-content flex-y cross-center"
                v-if="activeTool1 === 'all'"
              >
                <chart
                  chart-id="type-1-chart1"
                  :chart-height="120"
                  chart-width="100%"
                  :options="chart1Options"
                />
                <div
                  class="line-item"
                  v-for="(item, index) in chartList"
                  :key="index"
                >
                  <div class="item-top">
                    <div
                      class="legend-round-icon"
                      :style="{
                        backgroundColor: colorList[index]
                      }"
                    ></div>
                    <span>{{ item.name }}</span>
                    <span class="right">{{
                      item.percent
                    }}</span>
                    <span class="right"
                      >{{ item.value
                      }}<span style="font-weight: 400"
                        >公顷</span
                      ></span
                    >
                  </div>
                </div>
              </div>
              <div
                class="chart-wrapper-content flex-y cross-center"
                v-if="activeTool1 === 'city'"
              >
                <chart
                  chart-id="type-1-chart1"
                  :chart-height="120"
                  chart-width="100%"
                  :options="chart2Options"
                />
                <div
                  class="line-item"
                  v-for="(item, index) in chartList1"
                  :key="index"
                >
                  <div class="item-top">
                    <div
                      class="legend-round-icon"
                      :style="{
                        backgroundColor: colorList[index]
                      }"
                    ></div>
                    <span>{{ item.name }}</span>
                    <span class="right">{{
                      item.percent
                    }}</span>
                    <span class="right"
                      >{{ item.value
                      }}<span style="font-weight: 400"
                        >公顷</span
                      ></span
                    >
                  </div>
                </div>
              </div>
            </div>
            <!-- 用地规划 -->
            <!-- <div class="chart-wrapper flex-y" v-if="currentChildItem === 0">
              <div class="title flex-x cross-center">
                <img
                  class="title-prefix"
                  :src="TitlePrefix"
                  alt="标题前缀"
                />
                <span>全域用地规划</span>
              </div>
              <div class="chart-wrapper-content flex-y cross-center">
                <div class="line-item" v-for="(item,index) in chartList" :key="index">
                  <div class="item-top">
                    <span>{{item.name}}</span>
                    <span class="right">{{item.percent}}</span>
                    <span class="left-span">{{item.value}}公顷</span>
                  </div>
                  <div class="item-bottom">
                    <div :style="{width:item.percent}"></div>
                  </div>
                </div>
              </div>
            </div> -->

            <!-- 控规单元 -->
            <div
              v-if="currentChildItem === 1"
              class="plan-unit flex-y"
            >
              <div class="title flex-x cross-center">
                <img
                  class="title-prefix"
                  :src="TitlePrefix"
                  alt="标题前缀"
                />
                <span>控规单元</span>
              </div>
              <div
                class="plan-unit-item flex-x main-between cross-center"
                :class="{ first: index === 0 }"
                v-for="(item, index) in planUnitData"
                :key="index"
              >
                <span>{{ item.a }}</span>
                <span>{{ item.b }}</span>
              </div>
            </div>

            <img
              v-if="currentChildItem === 1"
              class="line-separator"
              :src="LineSeparator"
              alt="分割线"
            />

            <div
              class="chart-wrapper flex-y"
              v-if="currentChildItem === 1"
            >
              <div class="title flex-x cross-center">
                <img
                  class="title-prefix"
                  :src="TitlePrefix"
                  alt="标题前缀"
                />
                <span>用地规划</span>
              </div>
              <div
                class="chart-wrapper-content flex-y cross-center"
              >
                <div
                  class="line-item"
                  v-for="(item, index) in chartList2"
                  :key="index"
                >
                  <!-- <el-tooltip class="item" effect="dark" :content="item.percent" placement="top"> -->
                  <div
                    class="item-top"
                    style="margin-bottom: 6px"
                  >
                    <span>{{ item.name }}</span>
                    <!-- <span class="right">{{item.percent}}</span> -->
                    <span class="right"
                      >{{ item.value
                      }}<span style="font-weight: 400"
                        >公顷</span
                      ></span
                    >
                    <span class="right"></span>
                  </div>
                  <!-- </el-tooltip> -->
                  <!-- <el-tooltip class="item" effect="dark" :content="item.percent" placement="top"> -->
                  <div class="item-bottom">
                    <div
                      :style="{
                        width:
                          (item.value / 648.35).toFixed(4) *
                            100 +
                          '%'
                      }"
                    ></div>
                  </div>
                  <!-- </el-tooltip> -->
                </div>
              </div>
            </div>
            <!--            <img-->
            <!--            v-if="currentChildItem === 1"-->
            <!--              class="line-separator"-->
            <!--              :src="LineSeparator"-->
            <!--              alt="分割线"-->
            <!--            />-->
            <!-- 产业布局 -->
            <!-- <div
              v-if="currentChildItem === 0"
              class="chart-wrapper flex-y"
            >
              <div class="title flex-x cross-center">
                <img
                  class="title-prefix"
                  :src="TitlePrefix"
                  alt="标题前缀"
                />
                <span>中心城区用地规划</span>
              </div>
              <div class="chart-wrapper-content flex-y cross-center">
                <div class="line-item" v-for="(item,index) in chartList1" :key="index">
                  <div class="item-top">
                    <span>{{item.name}}</span>
                    <span class="right">{{item.percent}}</span>
                    <span class="left-span">{{item.value}}公顷</span>
                  </div>
                  <div class="item-bottom">
                    <div :style="{width:item.percent}"></div>
                  </div>
                </div>
              </div>
            </div> -->
          </div>
          <div
            v-show="activeTool === 'data'"
            style="padding: 10px"
          >
            <div class="left-content-title">
              <div class="left-content-title-l"></div>
              <p class="left-content-title-r">数据统计</p>
              <Icon
                title="筛选"
                :name="
                  filterPanelVisible
                    ? 'shaixuanshouqi'
                    : 'shaixuan'
                "
                font-size="20"
                :color="
                  filterPanelVisible
                    ? 'rgba(0, 210, 255, 1)'
                    : '#D2E6F0'
                "
                @click.native="
                  filterPanelVisible = !filterPanelVisible
                "
              />
            </div>
            <el-form
              v-if="filterPanelVisible"
              label-position="top"
            >
              <el-form-item
                label="统计范围："
                class="tjfw"
                v-if="
                  this.activeLayer &&
                  (this.activeLayer.areaAgg === 1 ||
                    this.activeLayer.customAgg === 1)
                "
              >
                <el-cascader
                  v-if="this.activeLayer.areaAgg === 1"
                  v-model="statisticsForm.area"
                  popper-class="my-cascader"
                  :options="areaOptions"
                  :show-all-levels="false"
                  :props="{ checkStrictly: true }"
                  @change="cascaderChange"
                  @expand-change="cascaderExpandChange"
                />
                <Icon
                  v-if="this.activeLayer.customAgg === 1"
                  title="绘制"
                  name="zidingyi"
                  font-size="16"
                  style="display: inline-block"
                  color="rgba(0, 210, 255, 1)"
                  @click.native="drawCustomBound"
                />
                <span
                  v-if="this.activeLayer.customAgg === 1"
                  class="custom-bound"
                  @click="drawCustomBound"
                  >自定义范围</span
                >
              </el-form-item>
              <el-form-item label="统计图层：">
                <el-select
                  style="width: 100%"
                  :popper-append-to-body="false"
                  v-model="statisticsForm.layer"
                  @change="layerChange"
                >
                  <el-option
                    v-for="item in layerOptions"
                    :key="item.pkid"
                    :label="item.sourceName"
                    :value="item.pkid"
                  />
                </el-select>
              </el-form-item>
              <el-form-item
                style="width: 100%"
                label="统计指标："
                v-if="
                  this.activeLayer &&
                  this.activeLayer.showChart
                "
              >
                <el-select
                  :popper-append-to-body="false"
                  v-model="statisticsForm.target"
                  clearable
                >
                  <el-option
                    v-for="item in targetOptions"
                    :key="item.field"
                    :label="item.caption"
                    :value="item.field"
                  />
                </el-select>
              </el-form-item>
              <el-form-item
                label="分类字段："
                v-if="
                  this.activeLayer &&
                  this.activeLayer.showChart
                "
              >
                <el-select
                  style="width: 100%"
                  :popper-append-to-body="false"
                  v-model="statisticsForm.label"
                  clearable
                >
                  <el-option
                    v-for="item in labelOptions"
                    :key="item.field"
                    :label="item.caption"
                    :value="item.field"
                  />
                </el-select>
              </el-form-item>
              <el-form-item
                style="width: 100%"
                label="统计方式："
                v-if="
                  this.activeLayer &&
                  this.activeLayer.showChart
                "
              >
                <el-select
                  :popper-append-to-body="false"
                  v-model="statisticsForm.statistics"
                  clearable
                >
                  <el-option
                    v-for="item in statisticsOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  />
                </el-select>
              </el-form-item>
            </el-form>
            <Chart1
              v-if="dataOption1 && dataOption2"
              class="right-content-echart"
              :chart1-height="chart1Height"
              :chart-data1="dataOption1"
              :chart-data2="dataOption2"
            />
          </div>
        </el-scrollbar>
      </div>

      <div
        class="left-close"
        @click="leftHide = !leftHide"
      ></div>

      <div
        class="bar"
        @mousedown.prevent="handleLeftMouseDown"
      ></div>
    </div>
  </div>
</template>

<script>
import axios from 'axios'

import {
  statisticsQuery,
  topicDefaultList
} from '@/api/tree'
import { squareKilometer } from '@/utils/constant'
import GuihuaBackground from '@/assets/img/guihua-area-background.png'
import Guihua from '@/assets/img/guihua-area.png'
import LineSeparator from '@/assets/img/line-separator.png'
import TitlePrefix from '@/assets/img/title-prefix.png'
import SpaceStructure from '@/assets/img/space-structure.png'
import PlanTargetBackground from '@/assets/img/plan-target-background.png'
import Chart from '@/components/chart/index'
import PlanStepper from '@/components/planStepper'
import Icon from '@/components/icon/index'
import New from '@/utils/new'
import Chart1 from './components/chart1'
import { getAreaData } from '@/api/area'
import { getAction } from '@/utils/helper'
import { globalBaseMap } from '@/utils/basemap'
import { retrieveDataServiceById } from '@/api/multiple-dataservice'

// let loadingInstance

let customAreaHandlerPolygon

let _mapViewer, _layerManager

export default {
  name: 'Blueprint',
  components: {
    Chart,
    PlanStepper,
    Icon,
    Chart1
  },
  inject: ['viewerId'],
  data() {
    return {
      GuihuaBackground,
      Guihua,
      LineSeparator,
      TitlePrefix,
      SpaceStructure,
      PlanTargetBackground,
      squareKilometerSymbol: squareKilometer,
      currentChildItem: 0,
      leftHide: false,
      chart1Options: {
        title: {
          text: '6042.83',
          left: 'center',
          top: '35%',
          textStyle: {
            color: '#fff',
            fontSize: '16px'
          }
        },
        tooltip: {
          trigger: 'item',
          formatter: '{b} <br/> {c}公顷 ({d}%)',
          confine: true
        },
        color: [
          '#FFA862',
          '#2663FF',
          '#20F6C6',
          '#FFDDA2',
          '#FF8080',
          '#00FF6C',
          '#FFF600',
          '#B1832B',
          '#00C0FF',
          '#B0FFE8',
          '#00FFFF'
        ],
        graphic: {
          type: 'text',
          left: 'center',
          top: '55%',
          style: {
            text: '公顷',
            fill: '#fff',
            fontSize: '14px'
          }
        },
        series: [
          {
            name: '用地规划',
            type: 'pie',
            radius: ['70%', '90%'],
            avoidLabelOverlap: false,
            label: {
              show: false,
              color: 'white',
              alignTo: 'none',
              formatter: '{d}%'
            },
            labelLayout: {
              hideOverlap: true
            },
            labelLine: {
              length: 5,
              length2: 10
            },
            emphasis: {
              scaleSize: 3
            },
            data: [
              { value: 8.26, name: '住宅、商业用地' },
              { value: 10.05, name: '工业用地' },
              {
                value: 4.2,
                name: '公共管理与公共服务设施用地'
              },
              { value: 8.09, name: '公用设施及道路用地' },
              { value: 4.24, name: '绿地及水域' },
              { value: 9.56, name: '基本农田' },
              { value: 16.01, name: '农林用地' }
            ]
          }
        ]
      },
      chart2Options: {
        title: {
          text: '3243.91',
          left: 'center',
          top: '35%',
          textStyle: {
            color: '#fff',
            fontSize: '16px'
          }
        },
        tooltip: {
          trigger: 'item',
          formatter: '{b} <br/> {c}公顷 ({d}%)',
          confine: true
        },
        color: [
          '#FFA862',
          '#2663FF',
          '#20F6C6',
          '#FFDDA2',
          '#FF8080',
          '#00FF6C',
          '#FFF600',
          '#B1832B',
          '#00C0FF',
          '#B0FFE8',
          '#00FFFF'
        ],
        graphic: {
          type: 'text',
          left: 'center',
          top: '55%',
          style: {
            text: '公顷',
            fill: '#fff',
            fontSize: '14px'
          }
        },
        series: [
          {
            name: '产业布局',
            type: 'pie',
            radius: ['70%', '90%'],
            avoidLabelOverlap: false,
            label: {
              show: false,
              color: 'white',
              alignTo: 'none',
              formatter: '{d}%'
            },
            labelLayout: {
              hideOverlap: true
            },
            labelLine: {
              length: 5,
              length2: 10
            },
            emphasis: {
              scaleSize: 3
            },
            data: [
              { value: 841.29, name: '交通运输用地' },
              { value: 818.71, name: '工矿用地' },
              { value: 586.61, name: '居住用地' },
              {
                value: 431.65,
                name: '公共管理与公共服务用地'
              },
              { value: 418.41, name: '绿地与开敞空间用地' },
              { value: 113.64, name: '商业服务用地' },
              { value: 19.5, name: '其他用地' },
              { value: 17.38, name: '留白用地' },
              { value: 16.22, name: '公用设施用地' },
              { value: 0, name: '仓储用地' },
              { value: 0, name: '特殊用地' }
            ]
          }
        ]
      },
      planUnitData: [
        // {
        //   a: '控规单元',
        //   b: '面积'
        // },
        {
          a: '智造示范区',
          b: `16.86${squareKilometer}`
        },
        {
          a: '国际科教城北单元',
          b: `12.3${squareKilometer}`
        }
      ],
      toolData: [
        {
          label: '专题统计',
          value: 'topic'
        },
        {
          label: '数据分析',
          value: 'data'
        }
      ],
      activeTool: 'topic',
      toolData1: [
        {
          label: '全域用地规划',
          value: 'all'
        },
        {
          label: '中心城区用地规划',
          value: 'city'
        }
      ],
      activeTool1: 'all',
      // 统计数据
      statisticsForm: {
        layer: '',
        target: '',
        label: '',
        statistics: '',
        area: ''
      },
      points: [],
      areaList: [],
      areaOptions: [
        {
          label: '全部',
          value: 'all'
        }
      ],
      layerOptions: [],
      activeLayer: null,
      dataServiceUrl: '',
      targetOptions: [],
      labelOptions: [],
      statisticsOptions: [
        {
          label: '平均值',
          value: 'AVG'
        },
        {
          label: '计数',
          value: 'COUNT'
        },
        {
          label: '求和',
          value: 'SUM'
        }
      ],
      chart1Height: 0,
      dataOption1: null,
      dataOption2: null,
      filterPanelVisible: false,
      menuShow: false,
      colorList: [
        '#FFA862',
        '#2663FF',
        '#20F6C6',
        '#FFDDA2',
        '#FF8080',
        '#00FF6C',
        '#FFF600',
        '#B1832B',
        '#00C0FF',
        '#B0FFE8',
        '#00FFFF'
      ],
      chartList: [
        {
          value: 8.26,
          name: '住宅、商业用地',
          percent: '14%'
        },
        { value: 10.05, name: '工业用地', percent: '17%' },
        {
          value: 4.2,
          name: '公共管理与公共服务设施用地',
          percent: '7%'
        },
        {
          value: 8.09,
          name: '公用设施及道路用地',
          percent: '13%'
        },
        { value: 4.24, name: '绿地及水域', percent: '7%' },
        { value: 9.56, name: '基本农田', percent: '16%' },
        { value: 16.01, name: '农林用地', percent: '27%' }
      ],
      chartList1: [
        {
          value: 841.29,
          name: '交通运输用地',
          percent: '25.78%'
        },
        {
          value: 818.71,
          name: '工矿用地',
          percent: '25.09%'
        },
        {
          value: 586.61,
          name: '居住用地',
          percent: '17.98%'
        },
        {
          value: 431.65,
          name: '公共管理与公共服务用地',
          percent: '13.23%'
        },
        {
          value: 418.41,
          name: '绿地与开敞空间用地',
          percent: '12.82%'
        },
        {
          value: 113.64,
          name: '商业服务用地',
          percent: '3.84%'
        },
        { value: 19.5, name: '其他用地', percent: '0.60%' },
        {
          value: 17.38,
          name: '留白用地',
          percent: '0.53%'
        },
        {
          value: 16.22,
          name: '公用设施用地',
          percent: '0.50%'
        },
        { value: 0, name: '仓储用地', percent: '0%' },
        { value: 0, name: '特殊用地', percent: '0%' }
      ],
      chartList2: [
        {
          value: 648.35,
          name: '交通设施用地',
          percent: '22.23%'
        },
        {
          value: 631.9,
          name: '一类工业用地',
          percent: '21.67%'
        },
        {
          value: 379.7,
          name: '居住用地',
          percent: '13.02%'
        },
        {
          value: 366.65,
          name: '公共管理与公共服务设施用地',
          percent: '12.57%'
        },
        {
          value: 361.73,
          name: '绿地与广场用地',
          percent: '12.40%'
        },
        {
          value: 229.26,
          name: '非建设用地',
          percent: '7.89%'
        },
        {
          value: 161.91,
          name: '住兼商用地',
          percent: '5.55%'
        },
        {
          value: 84.03,
          name: '商业服务业设施用地',
          percent: '2.88%'
        },
        {
          value: 32.81,
          name: '新型产业用地',
          percent: '1.13%'
        },
        {
          value: 19.13,
          name: '公用设施用地',
          percent: '0.66%'
        }
        // { value: 19.5, name: '其他用地' ,percent:'0.60%'},
      ],
      loading: false
    }
  },
  async created() {
    const { viewer, layerManager } = await getAction(
      this.viewerId
    )
    _mapViewer = viewer
    _layerManager = layerManager

    topicDefaultList('weilailantu-zonggui').then(
      async (res) => {
        if (res.success && res.data) {
          for await (const item of res.data.reverse()) {
            item.dataList = await this.getDataList(
              item.pkid
            )
            if (!item.dataList.length) {
              return
            }
            item.serviceUrl = item.dataList[0].serviceUrl
            item.signService = item.dataList[0].signService
            item.currentDataIndex = 0
            this.$bus.$emit('showDataList', item)
            await _layerManager.addAsync(item)
          }
        }
      }
    )
  },
  mounted() {
    New.$on('layerList', (data) => {
      this.layerOptions =
        data.filter(
          (item) =>
            // item.serviceType !== '27' &&
            item.showChart === 1
        ) || []
      // 如果图层选项中没有当前已选中的图层，则恢复已选中状态
      if (this.layerOptions.length) {
        if (
          this.activeLayer &&
          this.layerOptions.every(
            (item) => item.pkid !== this.activeLayer.pkid
          )
        ) {
          this.activeLayer = null
          this.statisticsForm = {
            layer: '',
            target: '',
            label: '',
            statistics: ''
          }
        }
      } else {
        this.activeLayer = null
        this.statisticsForm = {
          layer: '',
          target: '',
          label: '',
          statistics: ''
        }
      }
    })
    New.$on('blueShow', (data) => {
      this.menuShow = data
    })
  },
  methods: {
    cascaderChange(value) {
      const parentAreaCode = value[0]
      const childAreaCode =
        value.length === 2 ? value[1] : null
      const currentAreaCode =
        childAreaCode || parentAreaCode
      this.statisticsForm = Object.assign(
        this.statisticsForm,
        {
          area: currentAreaCode
        }
      )
      console.log('cascaderChange', currentAreaCode)
    },
    cascaderExpandChange(value) {
      const parentAreaCode = value[0]
      const parent = this.areaList.find(
        (item) => item.value === parentAreaCode
      )
      if (
        parentAreaCode !== 'all' &&
        parentAreaCode !== 'custom' &&
        parent &&
        parent.children.length === 0
      ) {
        this.showLoading()
        getAreaData(parentAreaCode)
          .then((res) => {
            this.hideLoading()
            const { data } = res
            if (data) {
              parent.children = data.map((item) => {
                return {
                  label: item.name,
                  value: item.areaCode,
                  region: JSON.parse(item.region)
                }
              })
            }
          })
          .catch((err) => {
            console.error(err)
            this.hideLoading()
          })
      }
    },
    async layerChange(e, append) {
      this.activeLayer = this.layerOptions.find((item) => {
        return item.pkid === e
      })
      if (append) {
        this.statisticsForm.layer = this.activeLayer.pkid
      }
      this.points = []
      this.areaOptions = [
        {
          label: '全部',
          value: 'all'
        }
      ]
      if (this.activeLayer.areaAgg !== 1) {
        this.$set(this.statisticsForm, 'area', 'all')
      } else {
        this.$set(this.statisticsForm, 'area', '')
      }
      this.statisticsForm.label = ''
      this.statisticsForm.target = ''
      this.statisticsForm.statistics = ''
      this.dataOption1 = null
      this.dataOption2 = null
      if (this.activeLayer.showChart) {
        if (this.activeLayer.areaAgg === 1) {
          if (this.areaList.length === 0) {
            console.log('无行政区划数据，请求')

            this.showLoading()
            getAreaData(1)
              .then((res) => {
                this.hideLoading()
                this.areaList.push(
                  ...res.data.map((item) => {
                    return {
                      label: item.name,
                      value: item.areaCode,
                      region: JSON.parse(item.region),
                      children: []
                    }
                  })
                )
                this.areaOptions.push(...this.areaList)
              })
              .catch((err) => {
                console.error(err)
                this.hideLoading()
              })
          } else {
            console.log('有行政区划数据，不请求')
            this.areaOptions = [
              {
                label: '全部',
                value: 'all'
              },
              ...this.areaList
            ]
          }
        }
        let dataServiceUrl = ''
        const defaultService = this.activeLayer.dataList[
          this.activeLayer.currentDataIndex
        ].resourceServiceDataInfoList.find(
          (item) => item.isDefault
        )
        if (defaultService) {
          dataServiceUrl = defaultService.serviceDataUrl
        }
        this.dataServiceUrl = dataServiceUrl
        if (!this.dataServiceUrl) {
          this.$message.error(
            '该图层未配置数据统计服务地址'
          )
        } else {
          statisticsQuery({ serviceId: e }).then((res) => {
            if (res.success) {
              this.targetOptions = []
              this.labelOptions = []
              axios
                .get(this.dataServiceUrl + '/fields.json')
                .then((fieldRes) => {
                  const fieldList =
                    fieldRes.data.fieldNames.map(
                      (item, index) => {
                        return {
                          field: item,
                          url: fieldRes.data.childUriList[
                            index
                          ],
                          caption: item
                        }
                      }
                    )
                  fieldList.forEach((item) => {
                    axios
                      .get(item.url + '.json')
                      .then((jsonResult) => {
                        item.caption =
                          jsonResult.data.fieldInfo.caption
                      })
                  })
                  this.targetOptions = fieldList.filter(
                    (field) =>
                      res.data.aggFields.indexOf(
                        field.field
                      ) !== -1
                  )
                  this.labelOptions = fieldList.filter(
                    (field) =>
                      res.data.groupFields.indexOf(
                        field.field
                      ) !== -1
                  )
                  if (append) {
                    this.statisticsForm.area = 'all'
                    this.statisticsForm.target =
                      this.targetOptions[0].field
                    this.statisticsForm.label =
                      this.labelOptions[0].field
                  }
                })
                .catch(() => {
                  this.$message.error('获取字段失败')
                })
              const list = []
              // 重置统计方式选项
              this.statisticsOptions = [
                {
                  label: '平均值',
                  value: 'AVG'
                },
                {
                  label: '计数',
                  value: 'COUNT'
                },
                {
                  label: '求和',
                  value: 'SUM'
                }
              ]
              res.data.types.forEach((item) => {
                list.push(this.statisticsOptions[item])
              })
              this.statisticsOptions = list
              if (append) {
                this.statisticsForm.statistics =
                  this.statisticsOptions[0].value
              }
            } else {
              this.$message.error(res.message)
            }
          })
        }
      }
    },
    toolItemClickHandle(data) {
      const { value } = data
      this.activeTool =
        this.activeTool === value ? undefined : value
      // this.clearLayerStyle() // 清除楼样式
      // console.log('toolItemClickHandle', data)
    },
    toolItemClickHandleArea(data) {
      const { value } = data
      this.activeTool1 =
        this.activeTool1 === value ? undefined : value
      // this.clearLayerStyle() // 清除楼样式
      // console.log('toolItemClickHandle', data)
    },
    drawCustomBound() {
      if (!customAreaHandlerPolygon) {
        this.$bus.$emit('customAreaDrawActived', true)
        customAreaHandlerPolygon = new Cesium.DrawHandler(
          _mapViewer,
          Cesium.DrawMode.Polygon,
          Cesium.ClampMode.Ground
        )
        customAreaHandlerPolygon.activeEvt.addEventListener(
          (isActive) => {
            if (isActive === true) {
              _mapViewer.enableCursorStyle = false
              _mapViewer._element.style.cursor = ''
            } else {
              _mapViewer.enableCursorStyle = true
            }
          }
        )
        customAreaHandlerPolygon.drawEvt.addEventListener(
          (result) => {
            customAreaHandlerPolygon.polygon.show = true
            customAreaHandlerPolygon.polyline.show = true
            const regions = []
            for (const pt of result.object.positions) {
              const cartographic =
                Cesium.Cartographic.fromCartesian(pt)
              const longitude = Cesium.Math.toDegrees(
                cartographic.longitude
              )
              const latitude = Cesium.Math.toDegrees(
                cartographic.latitude
              )
              regions.push([latitude, longitude])
            }
            if (
              this.areaOptions.every(
                (option) => option.value !== 'custom'
              )
            ) {
              this.areaOptions.push({
                label: '自定义范围',
                value: 'custom'
              })
            }
            this.$set(this.statisticsForm, 'area', 'custom')
            this.points = regions
            // console.log('regions', regions)
            this.$bus.$emit('customAreaDrawActived', false)
            customAreaHandlerPolygon.clear()
            customAreaHandlerPolygon.deactivate()
            customAreaHandlerPolygon = null
          }
        )
        customAreaHandlerPolygon.activate()
      } else {
        this.$bus.$emit('customAreaDrawActived', false)
        customAreaHandlerPolygon.clear()
        customAreaHandlerPolygon.deactivate()
        customAreaHandlerPolygon = null
      }
    },
    showLoading() {
      this.loading = true
      // if (!loadingInstance) {
      //   loadingInstance = Loading.service({
      //     fullscreen: true
      //   })
      //   console.log('show loading')
      // }
    },
    hideLoading() {
      this.loading = false
      // if (loadingInstance) {
      //   this.$nextTick(() => {
      //     loadingInstance.close()
      //     loadingInstance = null
      //     console.log('hide loading')
      //   })
      // }
    },
    handleChildMenuItemClick(index) {
      this.currentChildItem = index
      if (index === 0) {
        New.$emit('topic', { type: 'weilailantu-zonggui' })
        _layerManager.layers.forEach((e) => {
          this.$bus.$emit('handleBimDel', e.id)
          _layerManager.del(e.id)
        })
        // 设置底图为无底图
        if (
          globalBaseMap[this.viewerId]
            .currentBasemapIndex !== 0
        ) {
          globalBaseMap[this.viewerId].switchBasemap(0)
        }
        topicDefaultList('weilailantu-zonggui').then(
          async (res) => {
            if (res.success && res.data) {
              for await (const item of res.data.reverse()) {
                item.dataList = await this.getDataList(
                  item.pkid
                )
                if (!item.dataList.length) {
                  return
                }
                item.serviceUrl =
                  item.dataList[0].serviceUrl
                item.signService =
                  item.dataList[0].signService
                item.currentDataIndex = 0
                this.$bus.$emit('showDataList', item)
                await _layerManager.addAsync(item)
              }
            }
          }
        )

        globalBaseMap[this.viewerId].getBasemapList(
          'weilailantu-zonggui'
        )
      } else {
        _layerManager.layers.forEach((e) => {
          this.$bus.$emit('handleBimDel', e.id)
          _layerManager.del(e.id)
        })
        // 设置底图为无底图
        if (
          globalBaseMap[this.viewerId]
            .currentBasemapIndex !== 0
        ) {
          globalBaseMap[this.viewerId].switchBasemap(0)
        }
        New.$emit('topic', { type: 'weilailantu-konggui' })
        topicDefaultList('weilailantu-konggui').then(
          async (res) => {
            if (res.success && res.data) {
              for await (const item of res.data.reverse()) {
                item.dataList = await this.getDataList(
                  item.pkid
                )
                if (!item.dataList.length) {
                  return
                }
                item.serviceUrl =
                  item.dataList[0].serviceUrl
                item.signService =
                  item.dataList[0].signService
                item.currentDataIndex = 0
                this.$bus.$emit('showDataList', item)
                await _layerManager.addAsync(item)
              }
            }
          }
        )

        globalBaseMap[this.viewerId].getBasemapList(
          'weilailantu-konggui'
        )
      }
    },
    handleLeftMouseDown(e) {
      this.leftX = e.clientX
      this.leftWidth = this.$refs.leftRef.offsetWidth
      document.documentElement.addEventListener(
        'mousemove',
        this.leftMove
      )
      document.documentElement.addEventListener(
        'mouseup',
        this.leftEnd
      )
    },
    leftMove(e) {
      let width = this.leftWidth + e.clientX - this.leftX
      width = width >= 500 ? 500 : width < 340 ? 340 : width
      this.$refs.leftRef.style['min-width'] = `${width}px`
      this.$refs.leftRef.style.setProperty(
        '--scroll-width',
        `${-width}px`
      )
    },
    leftEnd() {
      document.documentElement.removeEventListener(
        'mousemove',
        this.leftMove
      )
      document.documentElement.removeEventListener(
        'mouseup',
        this.leftEnd
      )
    },
    // 获取服务的地图服务列表
    async getDataList(pkid) {
      const list = []
      await retrieveDataServiceById({
        pageIndex: 1,
        pageSize: 999,
        serviceId: pkid
      }).then((res) => {
        if (res.success) {
          if (res.data && res.data.length) {
            // 将配置的数据列表赋给原始数据
            list.push(...res.data)
          } else {
            this.$message.warning('该服务未配置数据')
          }
        } else {
          this.$message.error(
            res.message || '服务数据查询失败'
          )
        }
      })
      return list
    }
  },
  watch: {
    statisticsForm: {
      handler(val) {
        // console.log('统计form', val)
        this.dataOption1 = null
        this.dataOption2 = null
        if (Object.values(val).every((item) => !!item)) {
          // http://chengyu.caupdwest.com:7000/iserver/services/data-KeJiChengShuJuKu/rest/data/datasources/A_%E7%8E%B0%E7%8A%B6%E6%95%B0%E6%8D%AE%E5%BA%93/datasets/%E7%8E%B0%E7%8A%B6_%E5%BB%BA%E8%AE%BE%E7%94%A8%E5%9C%B0_2000"
          const dataService = this.dataServiceUrl
          const dataServiceUrl =
            dataService.substring(
              0,
              dataService.lastIndexOf('/datasources/')
            ) + '/featureResults.rjson?returnContent=true'
          console.log('请求地址', dataServiceUrl)
          const dataSourceAndDataSet = dataService
            .substring(
              dataService.lastIndexOf('/datasources/') +
                '/datasources/'.length
            )
            .split('/datasets/')
            .map((item) => decodeURI(item))
          console.log('数据源:数据集', dataSourceAndDataSet)

          if (val.area === 'all') {
            // 所有范围
            const sqlParameter = {
              datasetNames: [
                `${dataSourceAndDataSet.join(':')}`
              ],
              getFeatureMode: 'SQL',
              queryParameter: {
                fields: [
                  `${val.statistics}(${val.target}) as alias_name`,
                  `${val.label}`
                ],
                groupBy: `${val.label}`
              }
            }
            const queryData = JSON.stringify(sqlParameter)
            axios
              .post(dataServiceUrl, queryData)
              .then((res) => {
                // console.log('res.data', res.data)
                if (res.data.featureCount > 0) {
                  // 表1数据
                  const dataList = []
                  const xLabels = []
                  // 表2数据
                  const dataList2 = []
                  for (
                    let i = 0;
                    i < res.data.features.length;
                    i++
                  ) {
                    const dataItem =
                      res.data.features[i].fieldValues[0]
                    try {
                      const temp =
                        Number.parseFloat(dataItem)
                      dataList.push(temp.toFixed(2))
                      dataList2.push({
                        value: temp.toFixed(2),
                        name: res.data.features[i]
                          .fieldValues[1]
                      })
                    } catch (e) {
                      dataList.push(dataItem)
                      dataList2.push({
                        value: dataItem,
                        name: res.data.features[i]
                          .fieldValues[1]
                      })
                    }
                    xLabels.push(
                      res.data.features[i].fieldValues[1]
                    )
                  }
                  this.chart1Height =
                    xLabels.length * 20 +
                    (xLabels.length - 1) * 20 +
                    20 +
                    20
                  this.dataOption1 = {
                    tooltip: {
                      trigger: 'item',
                      position: function (
                        point,
                        params,
                        dom,
                        rect,
                        size
                      ) {
                        //  size为当前窗口大小
                        if (
                          size.viewSize[0] / 2 >=
                          point[0]
                        ) {
                          // 其中point为当前鼠标的位置,在左侧
                          return {
                            right: point[0],
                            top: point[1]
                          }
                        } else {
                          // 其中point为当前鼠标的位置
                          return {
                            right:
                              point[0] -
                              size.viewSize[0] / 2,
                            top: point[1]
                          }
                        }
                      }
                    },
                    // dataZoom:
                    //   dataList.length > 10
                    //     ? [
                    //         {
                    //           type: 'inside'
                    //         },
                    //         {
                    //           type: 'slider'
                    //         }
                    //       ]
                    //     : null,
                    yAxis: {
                      type: 'category',
                      data: xLabels,
                      axisTick: {
                        show: false
                        // 去除刻度
                      },
                      axisLabel: {
                        show: true,
                        interval: 0,
                        // rotate: 40,
                        textStyle: {
                          color: '#fff',
                          fontSize: 12
                        }
                      }
                    },
                    grid: {
                      left: '0%',
                      right: '1%',
                      top: '20',
                      bottom: '20',
                      containLabel: true
                    },
                    xAxis: {
                      type: 'value',
                      axisTick: {
                        show: false
                        // 去除刻度
                      },
                      axisLine: {
                        show: false,
                        lineStyle: {
                          color: '#fff'
                        }
                      },
                      axisLabel: {
                        show: false
                      },
                      splitLine: {
                        lineStyle: {
                          color: '#ffffff33'
                        }
                      }
                    },
                    series: [
                      {
                        data: dataList,
                        type: 'bar',
                        showBackground: true,
                        barWidth: '20',
                        barGap: '100%',
                        itemStyle: {
                          normal: {
                            color: '#00C8FF',
                            label: {
                              show: true,
                              position: 'top',
                              formatter: function (item) {
                                return item.data
                              },
                              textStyle: {
                                fontSize: 12,
                                color: '#ffffff'
                              }
                            }
                          }
                        },
                        backgroundStyle: {
                          color: 'rgba(255, 255, 255, 0.1)'
                        }
                      }
                    ]
                  }
                  this.dataOption2 = {
                    tooltip: {
                      trigger: 'item',
                      position: function (
                        point,
                        params,
                        dom,
                        rect,
                        size
                      ) {
                        //  size为当前窗口大小
                        if (
                          size.viewSize[0] / 2 >=
                          point[0]
                        ) {
                          // 其中point为当前鼠标的位置,在左侧
                          return {
                            right: point[0],
                            top: point[1]
                          }
                        } else {
                          // 其中point为当前鼠标的位置
                          return {
                            right:
                              point[0] -
                              size.viewSize[0] / 2,
                            top: point[1]
                          }
                        }
                      }
                    },
                    legend: {
                      show: false,
                      orient: 'vertical',
                      top: 10,
                      bottom: 10,
                      right: 10,
                      itemWidth: 7,
                      itemHeight: 7,
                      textStyle: {
                        color: '#fff'
                      },
                      itemStyle: {
                        borderType: 'solid'
                      },
                      type: 'scroll'
                    },
                    series: [
                      {
                        type: 'pie',
                        radius: ['20%', '50%'],
                        animation: false,
                        label: {
                          show: true,
                          color: '#fff',
                          position: 'top',
                          formatter: function (item) {
                            return item.value
                          }
                        },
                        tooltip: {
                          trigger: 'item',
                          formatter: '{b}: {d}%',
                          position: function (
                            point,
                            params,
                            dom,
                            rect,
                            size
                          ) {
                            //  size为当前窗口大小
                            if (
                              size.viewSize[0] / 2 >=
                              point[0]
                            ) {
                              // 其中point为当前鼠标的位置,在左侧
                              return {
                                right: point[0],
                                top: point[1]
                              }
                            } else {
                              // 其中point为当前鼠标的位置
                              return {
                                right:
                                  point[0] -
                                  size.viewSize[0] / 2,
                                top: point[1]
                              }
                            }
                          }
                        },
                        emphasis: {
                          itemStyle: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor:
                              'rgba(0, 0, 0, 0.5)'
                          }
                        },
                        labelLine: {
                          show: true
                        },
                        data: dataList2
                      }
                    ]
                  }
                }
              })
              .catch((err) => {
                console.error(err)
              })
          } else if (val.area === 'custom') {
            // 自定义范围
            const polygon = L.polygon([
              ...this.points,
              this.points[0]
            ])
            // 有范围，几何查询
            const param =
              new SuperMap.GetFeaturesByGeometryParameters({
                datasetNames: [
                  `${dataSourceAndDataSet.join(':')}`
                ],
                geometry: polygon,
                spatialQueryMode:
                  SuperMap.SpatialQueryMode.CONTAIN,
                fromIndex: 0,
                toIndex: 10000,
                fields: [
                  `${val.statistics}(${val.target}) as result`,
                  `${val.label}`
                ],
                groupBy: `${val.label}`
              })
            L.supermap
              .featureService(
                dataService.substring(
                  0,
                  dataService.lastIndexOf('/datasources/')
                )
              )
              .getFeaturesByGeometry(param, (result) => {
                // console.log('LeafletFeature result', result)
                // console.log(result.result.features.features)
                if (result.error) {
                  this.$message.error(
                    result.error.errorMsg || '范围查询失败'
                  )
                }
                if (result.result.featureCount > 0) {
                  // 表1数据
                  const dataList = []
                  const xLabels = []
                  // 表2数据
                  const dataList2 = []
                  for (
                    let i = 0;
                    i <
                    result.result.features.features.length;
                    i++
                  ) {
                    const dataItem =
                      result.result.features.features[i]
                        .properties['result']
                    try {
                      const temp =
                        Number.parseFloat(dataItem)
                      dataList.push(temp.toFixed(2))
                      dataList2.push({
                        value: temp.toFixed(2),
                        name: result.result.features
                          .features[i].properties[
                          `${val.label}`
                        ]
                      })
                    } catch (e) {
                      dataList.push(dataItem)
                      dataList2.push({
                        value: dataItem,
                        name: result.result.features
                          .features[i].properties[
                          `${val.label}`
                        ]
                      })
                    }
                    xLabels.push(
                      result.result.features.features[i]
                        .properties[`${val.label}`]
                    )
                  }
                  // console.log('dataList', dataList)
                  // console.log('xLabels', xLabels)
                  // console.log('dataList2', dataList2)
                  this.chart1Height =
                    xLabels.length * 20 +
                    (xLabels.length - 1) * 20 +
                    20 +
                    20
                  this.dataOption1 = {
                    tooltip: {
                      trigger: 'item',
                      position: function (
                        point,
                        params,
                        dom,
                        rect,
                        size
                      ) {
                        //  size为当前窗口大小
                        if (
                          size.viewSize[0] / 2 >=
                          point[0]
                        ) {
                          // 其中point为当前鼠标的位置,在左侧
                          return {
                            right: point[0],
                            top: point[1]
                          }
                        } else {
                          // 其中point为当前鼠标的位置
                          return {
                            right:
                              point[0] -
                              size.viewSize[0] / 2,
                            top: point[1]
                          }
                        }
                      }
                    },
                    // dataZoom:
                    //   dataList.length > 10
                    //     ? [
                    //         {
                    //           type: 'inside'
                    //         },
                    //         {
                    //           type: 'slider'
                    //         }
                    //       ]
                    //     : null,
                    yAxis: {
                      type: 'category',
                      data: xLabels,
                      axisTick: {
                        show: false
                        // 去除刻度
                      },
                      axisLabel: {
                        show: true,
                        interval: 0,
                        // rotate: 40,
                        textStyle: {
                          color: '#fff',
                          fontSize: 12
                        }
                      }
                    },
                    grid: {
                      left: '0%',
                      right: '1%',
                      top: '20',
                      bottom: '20',
                      containLabel: true
                    },
                    xAxis: {
                      type: 'value',
                      axisTick: {
                        show: false
                        // 去除刻度
                      },
                      axisLine: {
                        show: false,
                        lineStyle: {
                          color: '#fff'
                        }
                      },
                      axisLabel: {
                        show: false
                      },
                      splitLine: {
                        lineStyle: {
                          color: '#ffffff33'
                        }
                      }
                    },
                    series: [
                      {
                        data: dataList,
                        type: 'bar',
                        showBackground: true,
                        barWidth: '20',
                        barGap: '100%',
                        itemStyle: {
                          normal: {
                            color: '#00C8FF',
                            label: {
                              show: true,
                              position: 'top',
                              formatter: function (item) {
                                return item.data
                              },
                              textStyle: {
                                fontSize: 12,
                                color: '#ffffff'
                              }
                            }
                          }
                        },
                        backgroundStyle: {
                          color: 'rgba(255, 255, 255, 0.1)'
                        }
                      }
                    ]
                  }
                  this.dataOption2 = {
                    tooltip: {
                      trigger: 'item',
                      position: function (
                        point,
                        params,
                        dom,
                        rect,
                        size
                      ) {
                        //  size为当前窗口大小
                        if (
                          size.viewSize[0] / 2 >=
                          point[0]
                        ) {
                          // 其中point为当前鼠标的位置,在左侧
                          return {
                            right: point[0],
                            top: point[1]
                          }
                        } else {
                          // 其中point为当前鼠标的位置
                          return {
                            right:
                              point[0] -
                              size.viewSize[0] / 2,
                            top: point[1]
                          }
                        }
                      }
                    },
                    legend: {
                      show: false,
                      orient: 'vertical',
                      top: 10,
                      bottom: 10,
                      right: 10,
                      itemWidth: 7,
                      itemHeight: 7,
                      textStyle: {
                        color: '#fff'
                      },
                      itemStyle: {
                        borderType: 'solid'
                      },
                      type: 'scroll'
                    },
                    series: [
                      {
                        type: 'pie',
                        radius: ['20%', '50%'],
                        animation: false,
                        label: {
                          show: true,
                          color: '#fff',
                          position: 'top',
                          formatter: function (item) {
                            return item.value
                          }
                        },
                        tooltip: {
                          trigger: 'item',
                          formatter: '{b}: {d}%',
                          position: function (
                            point,
                            params,
                            dom,
                            rect,
                            size
                          ) {
                            //  size为当前窗口大小
                            if (
                              size.viewSize[0] / 2 >=
                              point[0]
                            ) {
                              // 其中point为当前鼠标的位置,在左侧
                              return {
                                right: point[0],
                                top: point[1]
                              }
                            } else {
                              // 其中point为当前鼠标的位置
                              return {
                                right:
                                  point[0] -
                                  size.viewSize[0] / 2,
                                top: point[1]
                              }
                            }
                          }
                        },
                        emphasis: {
                          itemStyle: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor:
                              'rgba(0, 0, 0, 0.5)'
                          }
                        },
                        labelLine: {
                          show: true
                        },
                        data: dataList2
                      }
                    ]
                  }
                }
              })
          } else {
            // 选择区域范围
            // 行政区划范围查询
            // const bounds = bounds2.map((item) => {
            //   return [item[1], item[0]]
            // })
            // const polygon = L.polygon([...bounds])
            let polygon
            const parent = this.areaOptions.find(
              (item) => item.value === val.area
            )
            if (parent) {
              polygon = L.polygon([...parent.region])
            } else {
              try {
                this.areaOptions.forEach((parent) => {
                  if (parent.children) {
                    const child = parent.children.find(
                      (childItem) =>
                        childItem.value === val.area
                    )
                    if (child) {
                      polygon = L.polygon([...child.region])
                      throw new Error('找到item，跳出循环')
                    }
                  }
                })
              } catch (e) {
                console.log(e)
              }
            }
            // const bounds = this.areaOptions.find((option) => option.label === val.area).bounds
            // const polygon = L.polygon([...bounds])
            // 有范围，几何查询
            const param =
              new SuperMap.GetFeaturesByGeometryParameters({
                datasetNames: [
                  `${dataSourceAndDataSet.join(':')}`
                ],
                geometry: polygon,
                spatialQueryMode:
                  SuperMap.SpatialQueryMode.CONTAIN,
                fromIndex: 0,
                toIndex: 10000,
                fields: [
                  `${val.statistics}(${val.target}) as result`,
                  `${val.label}`
                ],
                groupBy: `${val.label}`
              })
            L.supermap
              .featureService(
                dataService.substring(
                  0,
                  dataService.lastIndexOf('/datasources/')
                )
              )
              .getFeaturesByGeometry(param, (result) => {
                // console.log('LeafletFeature result', result)
                // console.log(result.result.features.features)
                if (result.error) {
                  this.$message.error(
                    result.error.errorMsg || '范围查询失败'
                  )
                }
                if (result.result.featureCount > 0) {
                  // 表1数据
                  const dataList = []
                  const xLabels = []
                  // 表2数据
                  const dataList2 = []
                  for (
                    let i = 0;
                    i <
                    result.result.features.features.length;
                    i++
                  ) {
                    const dataItem =
                      result.result.features.features[i]
                        .properties['result']
                    try {
                      const temp =
                        Number.parseFloat(dataItem)
                      dataList.push(temp.toFixed(2))
                      dataList2.push({
                        value: temp.toFixed(2),
                        name: result.result.features
                          .features[i].properties[
                          `${val.label}`
                        ]
                      })
                    } catch (e) {
                      dataList.push(dataItem)
                      dataList2.push({
                        value: dataItem,
                        name: result.result.features
                          .features[i].properties[
                          `${val.label}`
                        ]
                      })
                    }
                    xLabels.push(
                      result.result.features.features[i]
                        .properties[`${val.label}`]
                    )
                  }
                  // console.log('dataList', dataList)
                  // console.log('xLabels', xLabels)
                  // console.log('dataList2', dataList2)
                  this.chart1Height =
                    xLabels.length * 20 +
                    (xLabels.length - 1) * 20 +
                    20 +
                    20
                  this.dataOption1 = {
                    tooltip: {
                      trigger: 'item',
                      position: function (
                        point,
                        params,
                        dom,
                        rect,
                        size
                      ) {
                        //  size为当前窗口大小
                        if (
                          size.viewSize[0] / 2 >=
                          point[0]
                        ) {
                          // 其中point为当前鼠标的位置,在左侧
                          return {
                            right: point[0],
                            top: point[1]
                          }
                        } else {
                          // 其中point为当前鼠标的位置
                          return {
                            right:
                              point[0] -
                              size.viewSize[0] / 2,
                            top: point[1]
                          }
                        }
                      }
                    },
                    // dataZoom:
                    //   dataList.length > 10
                    //     ? [
                    //         {
                    //           type: 'inside'
                    //         },
                    //         {
                    //           type: 'slider'
                    //         }
                    //       ]
                    //     : null,
                    yAxis: {
                      type: 'category',
                      data: xLabels,
                      axisTick: {
                        show: false
                        // 去除刻度
                      },
                      axisLabel: {
                        show: true,
                        interval: 0,
                        // rotate: 40,
                        textStyle: {
                          color: '#fff',
                          fontSize: 12
                        }
                      }
                    },
                    grid: {
                      left: '0%',
                      right: '1%',
                      top: '20',
                      bottom: '50',
                      containLabel: true
                    },
                    xAxis: {
                      type: 'value',
                      axisTick: {
                        show: false
                        // 去除刻度
                      },
                      axisLine: {
                        show: false,
                        lineStyle: {
                          color: '#fff'
                        }
                      },
                      axisLabel: {
                        show: false
                      },
                      splitLine: {
                        lineStyle: {
                          color: '#ffffff33'
                        }
                      }
                    },
                    series: [
                      {
                        data: dataList,
                        type: 'bar',
                        showBackground: true,
                        barWidth: '20',
                        barGap: '100%',
                        itemStyle: {
                          normal: {
                            color: '#00C8FF',
                            label: {
                              show: true,
                              position: 'top',
                              formatter: function (item) {
                                return item.data
                              },
                              textStyle: {
                                fontSize: 12,
                                color: '#ffffff'
                              }
                            }
                          }
                        },
                        backgroundStyle: {
                          color: 'rgba(255, 255, 255, 0.1)'
                        }
                      }
                    ]
                  }
                  this.dataOption2 = {
                    tooltip: {
                      trigger: 'item',
                      position: function (
                        point,
                        params,
                        dom,
                        rect,
                        size
                      ) {
                        //  size为当前窗口大小
                        if (
                          size.viewSize[0] / 2 >=
                          point[0]
                        ) {
                          // 其中point为当前鼠标的位置,在左侧
                          return {
                            right: point[0],
                            top: point[1]
                          }
                        } else {
                          // 其中point为当前鼠标的位置
                          return {
                            right:
                              point[0] -
                              size.viewSize[0] / 2,
                            top: point[1]
                          }
                        }
                      }
                    },
                    legend: {
                      show: false,
                      orient: 'vertical',
                      top: 10,
                      bottom: 10,
                      right: 10,
                      itemWidth: 7,
                      itemHeight: 7,
                      textStyle: {
                        color: '#fff'
                      },
                      itemStyle: {
                        borderType: 'solid'
                      },
                      type: 'scroll'
                    },
                    series: [
                      {
                        type: 'pie',
                        radius: ['20%', '50%'],
                        animation: false,
                        label: {
                          show: true,
                          color: '#fff',
                          position: 'top',
                          formatter: function (item) {
                            return item.value
                          }
                        },
                        tooltip: {
                          trigger: 'item',
                          formatter: '{b}: {d}%',
                          position: function (
                            point,
                            params,
                            dom,
                            rect,
                            size
                          ) {
                            //  size为当前窗口大小
                            if (
                              size.viewSize[0] / 2 >=
                              point[0]
                            ) {
                              // 其中point为当前鼠标的位置,在左侧
                              return {
                                right: point[0],
                                top: point[1]
                              }
                            } else {
                              // 其中point为当前鼠标的位置
                              return {
                                right:
                                  point[0] -
                                  size.viewSize[0] / 2,
                                top: point[1]
                              }
                            }
                          }
                        },
                        emphasis: {
                          itemStyle: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor:
                              'rgba(0, 0, 0, 0.5)'
                          }
                        },
                        labelLine: {
                          show: true
                        },
                        data: dataList2
                      }
                    ]
                  }
                }
              })
          }

          // const sqlParameter = {
          //   datasetNames: [
          //     `${dataSourceAndDataSet.join(':')}`
          //   ],
          //   getFeatureMode: 'SQL',
          //   queryParameter: {
          //     fields: [
          //       `${val.statistics}(${val.target}) as alias_name`,
          //       `${val.label}`
          //     ],
          //     groupBy: `${val.label}`
          //   }
          // }
          // console.log(sqlParameter)
          // const queryData = JSON.stringify(sqlParameter)
          // axios
          //   .post(dataServiceUrl, queryData)
          //   .then((res) => {
          //     console.log('res.data', res.data)
          //     if (res.data.featureCount > 0) {
          //       // 表1数据
          //       const dataList = []
          //       const xLabels = []
          //       // 表2数据
          //       const dataList2 = []
          //       for (
          //         let i = 0;
          //         i < res.data.features.length;
          //         i++
          //       ) {
          //         const dataItem =
          //           res.data.features[i].fieldValues[0]
          //         try {
          //           const temp = Number.parseFloat(dataItem)
          //           dataList.push(temp.toFixed(2))
          //           dataList2.push({
          //             value: temp.toFixed(2),
          //             name: res.data.features[i]
          //               .fieldValues[1]
          //           })
          //         } catch (e) {
          //           dataList.push(dataItem)
          //           dataList2.push({
          //             value: dataItem,
          //             name: res.data.features[i]
          //               .fieldValues[1]
          //           })
          //         }
          //         xLabels.push(
          //           res.data.features[i].fieldValues[1]
          //         )
          //       }
          //       this.chart1Height =
          //         xLabels.length * 20 +
          //         (xLabels.length - 1) * 20 +
          //         20 +
          //         20
          //       this.dataOption1 = {
          //         tooltip: {
          //           trigger: 'item',
          //           position: function (
          //             point,
          //             params,
          //             dom,
          //             rect,
          //             size
          //           ) {
          //             //  size为当前窗口大小
          //             if (
          //               size.viewSize[0] / 2 >=
          //               point[0]
          //             ) {
          //               // 其中point为当前鼠标的位置,在左侧
          //               return {
          //                 right: point[0],
          //                 top: point[1]
          //               }
          //             } else {
          //               // 其中point为当前鼠标的位置
          //               return {
          //                 right:
          //                   point[0] - size.viewSize[0] / 2,
          //                 top: point[1]
          //               }
          //             }
          //           }
          //         },
          //         // dataZoom:
          //         //   dataList.length > 10
          //         //     ? [
          //         //         {
          //         //           type: 'inside'
          //         //         },
          //         //         {
          //         //           type: 'slider'
          //         //         }
          //         //       ]
          //         //     : null,
          //         yAxis: {
          //           type: 'category',
          //           data: xLabels,
          //           axisTick: {
          //             show: false
          //             // 去除刻度
          //           },
          //           axisLabel: {
          //             show: true,
          //             interval: 0,
          //             // rotate: 40,
          //             textStyle: {
          //               color: '#fff',
          //               fontSize: 12
          //             }
          //           }
          //         },
          //         grid: {
          //           left: '0%',
          //           right: '1%',
          //           top: '20',
          //           bottom: '20',
          //           containLabel: true
          //         },
          //         xAxis: {
          //           type: 'value',
          //           axisTick: {
          //             show: false
          //             // 去除刻度
          //           },
          //           axisLine: {
          //             show: false,
          //             lineStyle: {
          //               color: '#fff'
          //             }
          //           },
          //           axisLabel: {
          //             show: false
          //           },
          //           splitLine: {
          //             lineStyle: {
          //               color: '#ffffff33'
          //             }
          //           }
          //         },
          //         series: [
          //           {
          //             data: dataList,
          //             type: 'bar',
          //             showBackground: true,
          //             barWidth: '20',
          //             barGap: '100%',
          //             itemStyle: {
          //               normal: {
          //                 color: '#00C8FF',
          //                 label: {
          //                   show: true,
          //                   position: 'top',
          //                   formatter: function (item) {
          //                     return item.data
          //                   },
          //                   // + '平方公里'
          //                   textStyle: {
          //                     fontSize: 12,
          //                     color: '#ffffff'
          //                     // color: function(params) {
          //                     //   // console.log(params,'==========')
          //                     //   var colorList = ['#00d988', '#ffffff', '#00d988', '#ffffff', '#00d988']
          //                     //   return colorList[params.dataIndex]
          //                     // }
          //                   }
          //                   // }
          //                 }
          //               }
          //             },
          //             backgroundStyle: {
          //               color: 'rgba(255, 255, 255, 0.1)'
          //             }
          //           }
          //         ]
          //       }
          //       this.dataOption2 = {
          //         tooltip: {
          //           trigger: 'item',
          //           position: function (
          //             point,
          //             params,
          //             dom,
          //             rect,
          //             size
          //           ) {
          //             //  size为当前窗口大小
          //             if (
          //               size.viewSize[0] / 2 >=
          //               point[0]
          //             ) {
          //               // 其中point为当前鼠标的位置,在左侧
          //               return {
          //                 right: point[0],
          //                 top: point[1]
          //               }
          //             } else {
          //               // 其中point为当前鼠标的位置
          //               return {
          //                 right:
          //                   point[0] - size.viewSize[0] / 2,
          //                 top: point[1]
          //               }
          //             }
          //           }
          //         },
          //         legend: {
          //           show: false,
          //           orient: 'vertical',
          //           top: 10,
          //           bottom: 10,
          //           right: 10,
          //           itemWidth: 7,
          //           itemHeight: 7,
          //           textStyle: {
          //             color: '#fff'
          //           },
          //           itemStyle: {
          //             borderType: 'solid'
          //           },
          //           type: 'scroll'
          //         },
          //         series: [
          //           {
          //             name: 'Access From',
          //             type: 'pie',
          //             left: 0,
          //             radius: ['20%', '50%'],
          //             animation: false,
          //             label: {
          //               show: true,
          //               color: '#fff',
          //               position: 'top',
          //               formatter: function (item) {
          //                 return item.value
          //               }
          //             },
          //             tooltip: {
          //               trigger: 'item',
          //               formatter: '{b}: {d}%',
          //               position: function (
          //                 point,
          //                 params,
          //                 dom,
          //                 rect,
          //                 size
          //               ) {
          //                 //  size为当前窗口大小
          //                 if (
          //                   size.viewSize[0] / 2 >=
          //                   point[0]
          //                 ) {
          //                   // 其中point为当前鼠标的位置,在左侧
          //                   return {
          //                     right: point[0],
          //                     top: point[1]
          //                   }
          //                 } else {
          //                   // 其中point为当前鼠标的位置
          //                   return {
          //                     right:
          //                       point[0] -
          //                       size.viewSize[0] / 2,
          //                     top: point[1]
          //                   }
          //                 }
          //               }
          //             },
          //             emphasis: {
          //               itemStyle: {
          //                 shadowBlur: 10,
          //                 shadowOffsetX: 0,
          //                 shadowColor: 'rgba(0, 0, 0, 0.5)'
          //               }
          //             },
          //             labelLine: {
          //               show: true
          //             },
          //             data: dataList2
          //           }
          //         ]
          //       }
          //     }
          //   })
          //   .catch((err) => {
          //     console.log('err', err)
          //   })
        } else {
          this.dataOption1 = null
          this.dataOption2 = null
        }
      },
      deep: true,
      immediate: true
    }
  }
}
</script>

<style lang="scss" scoped>
.child-menu {
  position: absolute;
  left: 42.5%;
  top: 75px;
  width: 117px;
  height: 100px;
  // width: 175px;
  // height: 38px;
  transform: translateX(-50%);
  background: rgba(17, 35, 51, 0.3);
  // background-image: url('~@/assets/img/child-menu-background.png');
  // background-repeat: no-repeat;
  // background-size: cover;

  & span {
    display: block;
    width: 100%;
    height: 50px;
    line-height: 50px;
    text-align: center;
    font-size: 14px;
    color: white;
    padding: 0 10px;
    cursor: pointer;

    &.active {
      font-size: 18px;
      font-family: Source Han Sans CN;
      font-weight: bold;
      // color: #000000;
      text-shadow: 0 3px 5px rgba(0, 0, 0, 0.35);
      // background-color: linear-gradient(180deg, #00CEFB 0%, #65FAFF 100%);
      // -webkit-background-clip: text;
      // -webkit-text-fill-color: transparent;
      // color: white;
      background-image: url('~@/assets/img/guihua-bg.png');
      background-repeat: no-repeat;
      background-size: 100% 100%;
    }
  }
}

.left {
  position: fixed;
  left: 0;
  top: 60px;
  width: 340px;
  height: calc(100% - 60px);
  padding: 14px 0 14px 14px;
  background-color: transparent;
  transition: all 1s;
  --scroll-width: -340px;

  &-content {
    width: calc(100% - 32px);
    height: 100%;
    margin: 20px auto;

    &-title:not(:first-child) {
      padding-top: 26px;
      border-top: 1px solid rgba(255, 255, 255, 0.2);
    }

    &-title {
      //padding-bottom: 10px;
      display: flex;
      align-items: center;
      justify-content: space-between;

      &-l {
        width: 4px;
        height: 12px;
        background: linear-gradient(0deg, #bcf8ff, #40ebff);
        border-radius: 0;
        margin-right: 10px;
      }

      &-r {
        flex: 1;
        word-break: keep-all;
        font-size: 14px;
        //font-weight: 800;
        background: white;
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    }

    &-echart {
      width: 100%;
      padding: 10px 0;
    }

    &-query {
      display: flex;
      align-items: center;
      justify-content: space-between;

      & span {
        word-break: keep-all;
        font-size: 14px;
        font-weight: 400;
        color: #ffffff;
      }

      &-draw {
        display: flex;
        align-items: center;

        & span {
          cursor: pointer;
          margin-left: 4px;
        }
      }

      ::v-deep {
        .el-input__inner {
          width: 80px;
          background-color: transparent;
          border: 1px solid rgba(255, 255, 255, 0.4);
          border-radius: 0;
          height: 30px;
          line-height: 30px;
          color: #fff;
        }

        .el-input__icon {
          line-height: 30px;
        }
      }
    }
  }

  &-panel {
    height: 100%;
    background-color: rgba(7, 13, 35, 0.5);

    ::v-deep {
      .el-scrollbar {
        height: 100%;

        &__wrap {
          overflow-x: hidden;
        }

        &__view {
          padding-right: 8px;
        }
      }
    }

    .header {
      position: relative;
      margin: 10px 20px 0 10px;
      width: 100%;

      &-area-wrapper {
        position: absolute;
        left: 45px;
        right: 0;
        height: 56px;
        background-image: url('~@/assets/img/area-wrapper-background.png');
        background-repeat: no-repeat;
        background-size: 100% 100%;
      }

      &-title {
        font-size: 16px;
        font-weight: bold;
        background: linear-gradient(
          180deg,
          white 0%,
          #a4bbdd 100%
        );
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        margin-left: 40px;
      }

      .area {
        font-size: 22px;
        font-weight: bold;
        color: white;
        margin-right: 30px;
      }

      .unit {
        font-size: 14px;
        font-weight: 400;
        color: white;
      }

      &-icon {
        width: 90px;
        height: 90px;
        min-width: 90px;
        min-height: 90px;
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 2;

        img.background {
          position: absolute;
          left: 0;
          top: 0;
          width: 90px;
          height: 90px;
        }

        img.center {
          width: 34px;
          height: 34px;
          z-index: 1;
        }
      }
    }

    .line-separator {
      width: 100%;
      padding: 0 8px;
      opacity: 0.5;
    }

    .chart-wrapper {
      padding: 10px 10px 10px 10px;

      &:last-of-type {
        padding-bottom: 20px;
      }

      &-content {
        margin-top: 10px;

        .line-item {
          width: 100%;

          .item-top {
            width: 100%;
            height: 26px;
            // margin-bottom: 4px;
            font-size: 12px;
            font-family: PingFang SC;
            font-weight: 400;
            color: #ffffff;
            line-height: 28px;
            position: relative;

            .legend-round-icon {
              display: inline-block;
              width: 8px;
              height: 8px;
              margin-right: 12px;
              // border-radius: 50%;
            }

            .right {
              float: right;
              font-family: DIN;
              font-weight: bold;

              &:last-child {
                position: absolute;
                right: 20%;
              }
            }

            .left-span {
              position: absolute;
              left: 50%;
              // float: left;
              // margin-left: 50%;
            }
          }

          .item-bottom {
            width: 100%;
            height: 3px;
            background-color: rgba(0, 0, 0, 0.5);

            div {
              height: 100%;
              background: linear-gradient(
                90deg,
                #0072ca,
                #00ffff
              );
            }
          }
        }

        // .chart {
        //   width: 50% !important;
        // }
      }

      .legend {
        &:not(:last-of-type) {
          margin-bottom: 4px;
        }

        &-round-icon {
          width: 7px;
          height: 7px;
          margin-right: 3px;
          // border-radius: 50%;

          &.blue {
            background-color: #696dff;
          }

          &.light-blue {
            background-color: #00ffff;
          }

          &.green {
            background-color: #00d075;
          }

          &.orange {
            background-color: #ffa862;
          }

          &.yellow {
            background-color: #ffdda2;
          }
        }

        &-title {
          font-size: 12px;
          font-weight: 400;
          color: white;
          margin-right: 6px;
        }

        &-value {
          font-size: 14px;
          font-weight: bold;
          color: white;
        }
      }

      .chart-title {
        font-size: 12px;
        font-weight: 400;
        color: #d2e6f0;
        align-self: flex-end;
        margin-top: 20px;
      }
    }

    .title {
      &-prefix {
        position: relative;
        top: 2px;
        width: 6px;
        height: 16px;
        margin-right: 5px;
        object-fit: fill;
      }

      span {
        font-size: 14px;
        font-weight: 800;
        line-height: 14px;
        background: linear-gradient(
          180deg,
          white 0%,
          #a4bbdd 100%
        );
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    }

    ::v-deep {
      .el-form {
        padding: 10px;

        &-item {
          margin-bottom: 10px;

          &__label {
            color: white;
            padding: 0;
            line-height: 16px;
          }

          &__content {
            .el-input {
              &__inner {
                color: white;
                background: rgba(255, 255, 255, 0.2);
                border: 1px solid rgba(255, 255, 255, 0.2);
              }
            }

            .el-select {
              width: 100%;
            }

            .el-cascader {
              width: 180px;
            }
          }
        }
      }
    }

    .other-wrapper {
      padding: 10px 10px 0 10px;
    }

    .plan-stepper {
      margin-top: 16px;
    }

    .space-structure {
      // margin-top: 8px;
      margin-top: 15px;

      &-title {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;

        &-item {
          font-size: 14px;
          font-weight: 400;
          color: #d2e6f0;
        }
      }

      &-image {
        width: 298px;
        margin: 10px 0;
        align-self: center;
      }

      // &-item {
      //   position: relative;
      //   width: 100%;
      //   height: 134px;
      //   background: linear-gradient(
      //     180deg,
      //     rgba(64, 88, 118, 0.3),
      //     rgba(8, 29, 59, 0.3)
      //   );
      //   border: 1px solid rgba(181, 201, 212, 0.3);
      //   border-radius: 8px;
      //   margin-top: 20px;

      //   div.label {
      //     width: 100%;
      //     font-size: 14px;
      //     text-align: left;
      //     padding-left: 16px;
      //     padding-right: 16px;
      //     //background: linear-gradient(
      //     //    180deg,
      //     //    white 0%,
      //     //    #a4bbdd 100%
      //     //);
      //     //-webkit-background-clip: text;
      //     //-webkit-text-fill-color: transparent;
      //     color: white;

      //     &:first-child {
      //       text-shadow: 0 2px 2px #0c141d;
      //       margin-top: 12px;
      //     }

      //     &:not(:last-of-type) {
      //       margin-bottom: 10px;
      //     }
      //   }

      //   span.label {
      //     font-size: 14px;
      //     //background: linear-gradient(
      //     //    180deg,
      //     //    white 0%,
      //     //    #a4bbdd 100%
      //     //);
      //     //-webkit-background-clip: text;
      //     //-webkit-text-fill-color: transparent;
      //     color: white;
      //     // margin-top: 16px;
      //     line-height: 50px;
      //     height: 50px;
      //   }

      //   .background {
      //     position: absolute;
      //     top: 0;
      //     left: 50%;
      //     transform: translate(-50%, -50%);
      //     width: 111px;
      //     height: 26px;
      //     background-image: url('~@/assets/img/diamond.png');
      //     background-repeat: no-repeat;

      //     span {
      //       font-size: 14px;
      //       font-weight: 800;
      //       color: white;
      //     }
      //   }
      // }

      // &-item:not(:last-of-type) {
      //   margin-right: 14px;
      // }
    }

    .plan-target {
      display: flex;
      justify-content: space-around;
      align-items: flex-start;
      margin-top: 27px;

      &-item {
        display: flex;
        flex-direction: column;
        align-items: center;

        &-icon {
          position: relative;
          display: flex;
          justify-content: center;
          align-items: center;
          width: 86px;
          height: 86px;

          .background {
            position: absolute;
            top: 0;
            left: 0;
            width: 86px;
            height: 86px;
          }
        }

        .title {
          font-size: 14px;
          line-height: 14px;
          color: white;
        }

        .value {
          margin-top: 16px;
          font-size: 16px;
          line-height: 16px;
          font-weight: 500;
          color: white;

          .unit {
            font-size: 12px;
            color: white;
          }
        }
      }
    }

    .plan-unit {
      padding: 22px 10px 38px 10px;

      .title {
        margin-bottom: 18px;
      }

      &-item {
        height: 44px;
        padding: 0 22px 0 13px;

        &.first {
          background-image: url('~@/assets/img/area-wrapper-background.png');
          font-size: 14px;
          color: #d2e6f0;
        }

        &:not(.first) {
          background-color: #ffffff10;
          font-size: 14px;
          color: white;
        }

        &:not(:last-of-type) {
          margin-bottom: 3px;
        }

        .title {
          margin-bottom: 18px;
        }
      }
    }
  }

  &-hide {
    left: var(--scroll-width);

    & > .left-close {
      background-color: red;

      &::before,
      &::after {
        transform-origin: 6px 1px;
      }
    }
  }

  ::v-deep {
    .el-scrollbar__wrap {
      overflow-x: hidden;

      .el-form {
        // background-image: url('../../../../public/img/basemaps/yxjz.png');
        padding-left: 10px;
        background-size: cover;
        background-repeat: no-repeat;
        padding-bottom: 1px !important;
        padding-top: 8px;
      }

      .el-form-item {
        margin-bottom: 0;

        &:last-child {
          margin-bottom: 7px;
        }
      }

      .el-form-item__label {
        padding: 0 !important;
        color: white !important;
        line-height: 20px !important;
      }

      .el-input__inner {
        background: rgba(65, 89, 117, 0.5) !important;
        border-color: #4a627f !important;
        height: 30px !important;
        color: #a7beca !important;
      }
    }
  }

  &-close {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 44px;
    cursor: pointer;
    background: #192f3d;
    opacity: 0.7;

    &::before,
    &::after {
      content: '';
      position: absolute;
      width: 7px;
      height: 2px;
      background: #fff;
      top: 50%;
      left: 50%;
      transform-origin: 1px 1px;
    }

    &::before {
      transform: translateX(-50%) translateY(-50%)
        rotateZ(-45deg);
    }

    &::after {
      transform: translateX(-50%) translateY(-50%)
        rotateZ(45deg);
    }
  }

  .bar {
    position: absolute;
    top: 0;
    right: 0;
    width: 3px;
    height: 100%;
    cursor: col-resize;
  }
}

.bimNav {
  &-title {
    display: flex;
    // background: url('../../../assets/bim/bim_right_top@2x.png');
    height: 40px;
    line-height: 40px;

    > div {
      margin-right: 10px;
      /*padding-bottom: 10px;*/
      cursor: pointer;
      font-size: 14px;
      font-family: PingFang SC;
      font-weight: bold;
      color: #d2e6f0;

      &:first-child {
        margin-left: 36px;
      }
    }

    .is-active {
      //background: url('../../../assets/bim/floor_check@2x.png');
      //background-size: 100% 100%;
      color: rgba(26, 217, 255, 1);
    }
  }
}

.bimNavArea {
  &-title {
    display: flex;
    // background: url('../../../assets/bim/bim_right_top@2x.png');
    height: 33px;
    line-height: 33px;
    font-weight: 800;
    color: #ffffff;
    font-family: PingFang SC;
    margin-bottom: 7px;

    > div {
      position: relative;
      margin-right: 10px;
      /*padding-bottom: 10px;*/
      cursor: pointer;
      font-size: 14px;
      // text-shadow: 0px 2px 2px #0C141D;
      background: linear-gradient(
        180deg,
        #ffffff 0%,
        #a4bbdd 100%
      );
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;

      &:first-child {
        margin-left: 36px;
      }
    }

    .is-active {
      //background: url('../../../assets/bim/floor_check@2x.png');
      //background-size: 100% 100%;
      // color: rgba(26, 217, 255, 1);
      text-shadow: 0 3px 5px rgba(0, 0, 0, 0.35);
      background: linear-gradient(
        180deg,
        #00cefb 0%,
        #65faff 100%
      );
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;

      &::after {
        content: '';
        position: absolute;
        left: 25%;
        bottom: 0;
        width: 50%;
        height: 2px;
        background: #00cefb;
      }
    }
  }
}

::v-deep {
  .el-select-dropdown {
    border-color: #4a80a3;

    .el-select-dropdown__empty {
      background-color: #4a80a3;
      color: white;
    }

    .el-select-dropdown__list {
      background-color: #4a80a3;

      .el-select-dropdown__item {
        color: white;
        background-color: #4a80a3;

        &.selected {
          color: white;
        }

        &.hover {
          background-color: #28516c;
        }
      }
    }

    .popper__arrow {
      border-bottom-color: #4a80a3;

      &::after {
        border-bottom-color: #4a80a3;
      }
    }
  }
}
</style>
